package com.pan.structual.adapter.tool;

import javax.swing.*;
import java.awt.*;
import java.util.List;

public enum ShowColorUtils {
    INSTANCE;{

    }
    public void createColorFrame(Color color){
        this.createColorFrame(color,"color frame");
    }

    private JFrame createFrame(){
        JFrame frame = new JFrame();
        // 设置窗口的位置、大小
        frame.setBounds(400,400,300, 200);
        // 设置窗口关闭时的操作
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        return frame;
    }
    public void createColorFrame(Color color,String frameName){
        JFrame frame = createFrame();
        frame.setTitle(frameName);
        // 设置窗口的背景颜色
        frame.getContentPane().setBackground(color);
        frame.setVisible(true);
    }


    public void createColorFrame(int[] rgbColor){
        this.createColorFrame(rgbColor,"color frame");
    }
    public void createColorFrame(int[] rgbColor,String frameName){
        JFrame frame = createFrame();
        frame.setTitle(frameName);
        frame.getContentPane().setBackground(
                new Color(rgbColor[0],rgbColor[1],rgbColor[2])
        );
        frame.setVisible(true);
    }


    public void showRGBColorList(List<int[]> colorList){
        for (int i = 0; i < colorList.size(); i++) {
            createColorFrame(colorList.get(i),"rgb color "+i);
        }
    }
    public void showAwtColorList(List<Color> colorList){
        for (int i = 0; i < colorList.size(); i++) {
            createColorFrame(colorList.get(i),"awt color "+i);
        }
    }
}
